//
//  UpdateServerDetailViewController.m
//  PYWGetColor
//
//  Created by 杜文杰 on 2018/6/28.
//  Copyright © 2018年 dwj. All rights reserved.
//

#import "UpdateServerDetailViewController.h"
#import "ZYQAssetPickerController.h"
#import "SelectPicCollectionViewCell.h"
#import "ChooseGetMoneyTypeView.h"

@interface UpdateServerDetailViewController ()<UITableViewDelegate,UITableViewDataSource,UITextViewDelegate,UICollectionViewDelegate,UICollectionViewDataSource,ZYQAssetPickerControllerDelegate,UINavigationControllerDelegate>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) UICollectionView *collectionView;
@property (nonatomic, strong) UIView *headerView;
@property (nonatomic, strong) UIView *footerView;

@property (nonatomic, strong) UITextView *titleTextView;      // 标题
@property (nonatomic, strong) UITextView *textView;      // 内容输入
@property (nonatomic, strong) UIButton *submmitButton;   // 确定按钮
@property (nonatomic, strong) NSMutableArray *dataArray; //数据源
@property (nonatomic, strong) UIButton * fullTimeBtn;
@property (nonatomic, strong) UIButton * partTimeBtn;
@property (nonatomic, strong) UIButton *pleaseChooseTypeBtn;
@property (nonatomic, strong) NSString *payType; // 收费方式
@property (nonatomic, strong) NSString *chooseJobType;// 全职（1）、兼职（2）
@property (nonatomic, strong) UITextField *priceField;// 价格
@end

@implementation UpdateServerDetailViewController
/**
 查看服务详情
 skillid 服务技能id
 */
- (void)haveLookServersList {
    [[AFAppDotNetAPIClient sharedClient] POST:@"interface.php?m=skilldetail" parameters:@{@"uid":[UserModel sharedInstanced].userId,@"token":[UserModel sharedInstanced].token,@"skillid":self.secondDataDic[@"skillid"]} progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        if ([responseObject[@"error_code"] isEqualToString:@"0"]) {
            NSDictionary *dic = responseObject[@"data"];
            self.titleTextView.text = dic[@"skilltitle"];
            self.textView.text = dic[@"skilldesc"];
            UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:dic[@"skillimg"]]]];
            if (image != nil || image != NULL) {
                [self.dataArray addObject:image];
            }
            [self.collectionView reloadData];
            if ([dic[@"type"] isEqualToString:@"1"]) { // 全职
                self.fullTimeBtn.selected = !self.fullTimeBtn.selected;
                if (self.fullTimeBtn.selected) {
                    [self.fullTimeBtn setBackgroundImage:[UIImage imageNamed:@"WechatIMG88x19"] forState:UIControlStateSelected];
                    [self.partTimeBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateSelected];
                    self.partTimeBtn.selected = NO;
                    self.chooseJobType = @"1";
                    self.fullTimeBtn.layer.borderColor = [UIColor clearColor].CGColor;
                }else{ // 兼职
                    [self.fullTimeBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateSelected];
                }
            }
            if ([dic[@"type"] isEqualToString:@"2"]) { // 兼职
                self.partTimeBtn.selected = !self.partTimeBtn.selected;
                if (self.partTimeBtn.selected) {
                    [self.partTimeBtn setBackgroundImage:[UIImage imageNamed:@"WechatIMG88x19"] forState:UIControlStateSelected];
                    [self.fullTimeBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateSelected];
                    self.fullTimeBtn.selected = NO;
                    self.chooseJobType = @"2";
                    self.partTimeBtn.layer.borderColor = [UIColor clearColor].CGColor;
                }else{ // 全职
                    [self.partTimeBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateSelected];
                }
            }
            if ([dic[@"payway"] isEqualToString:@"1"]) {
                [_pleaseChooseTypeBtn setTitle:@"一口价" forState:UIControlStateNormal];
                self.payType = @"1";
            }
            if ([dic[@"payway"] isEqualToString:@"2"]) {
                [_pleaseChooseTypeBtn setTitle:@"免费预约" forState:UIControlStateNormal];
                self.payType = @"2";
            }
            self.priceField.text = dic[@"amount"];
        }else{
            ShowMessage(@"操作失败");
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        [self showError:error];
    }];
}
// 修改信息上传
- (void)AddData{
    if (self.titleTextView.text.length <= 0) {
        ShowMessage(@"请输入标题");
        return;
    }
    if (self.textView.text.length <= 0) {
        ShowMessage(@"请输入内容");
        return;
    }
    if (self.priceField.text.length <= 0) {
        ShowMessage(@"请输入价格");
        return;
    }
    if (_dataArray == nil || [_dataArray isKindOfClass:[NSNull class]] || _dataArray.count == 0){
        ShowMessage(@"请选择文件图片");
        return;
    }
    [self showprogressHUD];
    NSDictionary *parameters = @{@"uid":[UserModel sharedInstanced].userId,@"token":[UserModel sharedInstanced].token,@"skillid":self.secondDataDic[@"skillid"],@"skilltitle":self.titleTextView.text,@"skilldesc":self.textView.text,@"type":self.chooseJobType.length > 0?self.chooseJobType : @"1",@"payway":self.payType.length > 0?self.payType : @"1",@"amount":self.priceField.text};
    [[AFAppDotNetAPIClient sharedClient] POST:@"interface.php?m=saveskill" parameters:parameters constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        for (UIImage *img in self.dataArray) {
            NSData *data = UIImageJPEGRepresentation(img, .2);
            NSString *imgName = [NSString stringWithFormat:@"%ld.jpg",(unsigned long)[NSDate date].timeIntervalSince1970];
            [formData appendPartWithFileData:data name:@"skillimg" fileName:imgName mimeType:@"image/jpeg"];
        }
    } progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        [self hiddenProgressHUD];
        if ([responseObject[@"error_code"] isEqualToString:@"0"]) {
            ShowMessage(@"保存成功");
            [self.view makeToast:@"保存成功" duration:1 position:CSToastPositionCenter title:nil image:nil style:nil completion:^(BOOL didTap) {
                [self.navigationController popViewControllerAnimated:YES];
            }];
        }else{
            ShowMessage(responseObject[@"msg"]);
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        [self hiddenProgressHUD];
        [self showError:error];
    }];
}
- (void)btnAction:(UIButton *)btn
{
    if ([btn isEqual:self.fullTimeBtn]) {
        self.fullTimeBtn.selected = !self.fullTimeBtn.selected;
        if (self.fullTimeBtn.selected) {
            [self.fullTimeBtn setBackgroundImage:[UIImage imageNamed:@"WechatIMG88x19"] forState:UIControlStateSelected];
            [self.partTimeBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateSelected];
            self.partTimeBtn.selected = NO;
            self.chooseJobType = @"1";
            self.fullTimeBtn.layer.borderColor = [UIColor clearColor].CGColor;
            self.partTimeBtn.layer.borderColor = getColor(dividerColor).CGColor;
        }else{
            [self.fullTimeBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateSelected];
            self.fullTimeBtn.layer.borderColor = getColor(dividerColor).CGColor;
        }
    }
    if ([btn isEqual:self.partTimeBtn]) {
        self.partTimeBtn.selected = !self.partTimeBtn.selected;
        if (self.partTimeBtn.selected) {
            [self.partTimeBtn setBackgroundImage:[UIImage imageNamed:@"WechatIMG88x19"] forState:UIControlStateSelected];
            [self.fullTimeBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateSelected];
            self.fullTimeBtn.selected = NO;
            self.chooseJobType = @"2";
            self.partTimeBtn.layer.borderColor = [UIColor clearColor].CGColor;
            self.fullTimeBtn.layer.borderColor = getColor(dividerColor).CGColor;
        }else{
            [self.partTimeBtn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateSelected];
            self.partTimeBtn.layer.borderColor = getColor(dividerColor).CGColor;
        }
    }
    if ([btn isEqual:self.submmitButton]) {
        NSLog(@"保存信息");
        [self AddData];
    }
    if ([btn isEqual:self.pleaseChooseTypeBtn]) {
        ChooseGetMoneyTypeView *chooseGetMoneyTypeView = [[ChooseGetMoneyTypeView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        chooseGetMoneyTypeView.sfTypeBlock = ^(NSDictionary *dic) {
            if ([dic[@"imgSelected"] isEqualToString:@"1"]) {
                NSLog(@"选中的是 %@ %@",dic[@"titleName"],dic[@"chooseID"]);
                [_pleaseChooseTypeBtn setTitle:dic[@"titleName"] forState:UIControlStateNormal];
                self.payType = dic[@"chooseID"];
            }
        };
        [chooseGetMoneyTypeView show];
        NSLog(@"请选择");
    }
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"服务详情";
    [self.view addSubview:self.tableView];
    [self haveLookServersList];
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.view endEditing:YES];
}
#pragma mark -- UITextViewDelefate
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
    if ([textView.text isEqualToString:@"请填写您的收费标准、服务内容、服务流程、服务保障等。详细的服务介绍可以吸引更多的客户下单。"]) {
        textView.textColor = [UIColor blackColor];
        textView.text = @"";
    }
    if ([textView.text isEqualToString:@"清晰明确的标题更吸引人哦"]) {
        textView.textColor = [UIColor blackColor];
        textView.text = @"";
    }
    return YES;
}
- (BOOL)textViewShouldEndEditing:(UITextView *)textView{
    if ([textView isEqual:_titleTextView]) {
        if ([textView.text isEqualToString:@""]) {
            textView.textColor = [UIColor grayColor];
            textView.text = @"清晰明确的标题更吸引人哦";;
        }
        return YES;
    }
    if ([textView.text isEqualToString:@""]) {
        textView.textColor = [UIColor grayColor];
        textView.text = @"请填写您的收费标准、服务内容、服务流程、服务保障等。详细的服务介绍可以吸引更多的客户下单。";;
    }
    return YES;
}
#pragma mark -- UITableViewDelegate & UITableViewDataSource
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([UITableViewCell class])];
    return cell;
}
#pragma mark -- UICollectionViewDelefage,UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return self.dataArray.count + 1;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    SelectPicCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([SelectPicCollectionViewCell class]) forIndexPath:indexPath];
    cell.deleteHandle = ^(){
        [self.dataArray removeObjectAtIndex:indexPath.row];
        [collectionView reloadData];
    };
    if (indexPath.row < self.dataArray.count) {
        cell.img = self.dataArray[indexPath.row];
    }else{
        cell.img = nil;
    }
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    if (self.dataArray.count >= 1) {
        NSLog(@"最多只能上传1张图片");
        ShowMessage(@"最多只能上传1张图片");
    }else{
        [self selectPictures];
    }
}

//选择图片
- (void)selectPictures{
    ZYQAssetPickerController *picker = [[ZYQAssetPickerController alloc] init];
    picker.maximumNumberOfSelection = 1-self.dataArray.count;
    picker.assetsFilter = [ALAssetsFilter allPhotos];
    picker.showEmptyGroups = NO;
    picker.delegate = self;
    picker.selectionFilter = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings){
        if ([[(ALAsset *)evaluatedObject valueForProperty:ALAssetPropertyType] isEqual:ALAssetTypeVideo]){
            NSTimeInterval duration = [[(ALAsset *)evaluatedObject valueForProperty:ALAssetPropertyDuration] doubleValue];
            return duration >= 5;
        } else {
            return YES;
        }
    }];
    
    [self presentViewController:picker animated:YES completion:NULL];
}

-(void)assetPickerController:(ZYQAssetPickerController *)picker didFinishPickingAssets:(NSArray *)assets{
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        for (int i=0; i<assets.count; i++){
            ALAsset *asset = assets[i];
            UIImage *tempImg = [UIImage imageWithCGImage:asset.defaultRepresentation.fullScreenImage];
//            NSData *dataWithImage;
//            //判断图片是不是png格式的文件
//            if (UIImagePNGRepresentation(tempImg)) {
//                //返回为png图像。
//                dataWithImage = UIImagePNGRepresentation(tempImg);
//            }else {
//                //            返回为JPEG图像。
//            }
            [self.dataArray addObject:tempImg];
            dispatch_async(dispatch_get_main_queue(), ^{
                [self.collectionView reloadData];
            });
        }
    });
}

#pragma mark -- init

- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - SafeAreaTopHeight - SafeAreaBottomHeight) style:UITableViewStyleGrouped];
        _tableView.backgroundColor = getColor(bgColor);
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.sectionFooterHeight = .01;
        _tableView.sectionHeaderHeight = .01;
        _tableView.tableFooterView = self.footerView;
        _tableView.tableHeaderView = self.headerView;
        _tableView.showsVerticalScrollIndicator = NO;
        _tableView.showsHorizontalScrollIndicator = NO;
        [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:NSStringFromClass([UITableViewCell class])];
    }
    return _tableView;
}

- (UIView *)headerView{
    if (!_headerView) {
        _headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 335 / HEIGHT_6S_SCALE)];
        _headerView.backgroundColor = [UIColor whiteColor];
        
        _titleTextView = [[UITextView alloc]initWithFrame:CGRectMake(10 / WIDTH_6S_SCALE, 0, SCREEN_WIDTH - 20 / WIDTH_6S_SCALE, 40 / HEIGHT_6S_SCALE)];
        _titleTextView.font = DEF_FontSize_16;
        _titleTextView.delegate = self;
        _titleTextView.text = @"清晰明确的标题更吸引人哦";
        _titleTextView.textColor = getColor(textColor);
        
        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(10 / WIDTH_6S_SCALE, CGRectGetMaxY(_titleTextView.frame) + 1, SCREEN_WIDTH - 10 / WIDTH_6S_SCALE, 1)];
        lineView.backgroundColor = getColor(dividerColor);
        
        _textView = [[UITextView alloc] initWithFrame:CGRectMake(10 / WIDTH_6S_SCALE, CGRectGetMaxY(_titleTextView.frame) + 10 / HEIGHT_6S_SCALE, SCREEN_WIDTH - 20 / WIDTH_6S_SCALE, 110 / HEIGHT_6S_SCALE)];
        _textView.font = DEF_FontSize_14;
        _textView.delegate = self;
        _textView.text = @"请填写您的收费标准、服务内容、服务流程、服务保障等。详细的服务介绍可以吸引更多的客户下单。";
        _textView.textColor = getColor(textColor);
        
        UICollectionViewFlowLayout *layout = [UICollectionViewFlowLayout new];
        layout.minimumLineSpacing = 10;
        layout.minimumInteritemSpacing = 10;
        layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        layout.itemSize = CGSizeMake(80/WIDTH_5S_SCALE, 80/WIDTH_5S_SCALE);
        layout.sectionInset = UIEdgeInsetsMake(0, 10, 0, 10);
        
        _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_textView.frame)+5/WIDTH_5S_SCALE, SCREEN_WIDTH, 80 / WIDTH_5S_SCALE) collectionViewLayout:layout];
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
        _collectionView.showsVerticalScrollIndicator = NO;
        _collectionView.showsHorizontalScrollIndicator = NO;
        _collectionView.bounces = NO;
        _collectionView.backgroundColor = [UIColor clearColor];
        [_collectionView registerClass:[SelectPicCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([SelectPicCollectionViewCell class])];
        
        UIView *lineView2 = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_collectionView.frame) + 25 / HEIGHT_6S_SCALE, SCREEN_WIDTH, 12 / HEIGHT_6S_SCALE)];
        lineView2.backgroundColor = getColor(dividerColor);
        
        [_headerView addSubview:_titleTextView];
        [_headerView addSubview:lineView];
        [_headerView addSubview:_textView];
        [_headerView addSubview:_collectionView];
        [_headerView addSubview:lineView2];
    }
    return _headerView;
}

- (UIView *)footerView{
    if (!_footerView) {
        _footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 220 / WIDTH_5S_SCALE + 44, SCREEN_WIDTH, 220/WIDTH_5S_SCALE + 44)];
        _footerView.backgroundColor = [UIColor whiteColor];
        
        UIButton * fullTimeBtn = [[UIButton alloc]initWithFrame:CGRectMake(10 / WIDTH_6S_SCALE, 10 / HEIGHT_6S_SCALE, (SCREEN_WIDTH - 30 / WIDTH_6S_SCALE) / 2, 37 / HEIGHT_6S_SCALE)];
        fullTimeBtn.backgroundColor = [UIColor clearColor];
        [fullTimeBtn setTitle:@"全职" forState:UIControlStateNormal];
        [fullTimeBtn setTitleColor:getColor(blackColor) forState:UIControlStateNormal];
        fullTimeBtn.layer.borderColor = getColor(dividerColor).CGColor;
        fullTimeBtn.layer.borderWidth = 1.5;
        fullTimeBtn.titleLabel.font = DEF_FontSize_14;
        [fullTimeBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
        self.fullTimeBtn = fullTimeBtn;
        [_footerView addSubview:fullTimeBtn];
        
        UIButton * partTimeBtn = [[UIButton alloc]initWithFrame:CGRectMake(CGRectGetMaxX(fullTimeBtn.frame) + 10 / WIDTH_6S_SCALE, 10 / HEIGHT_6S_SCALE, (SCREEN_WIDTH - 30 / WIDTH_6S_SCALE) / 2, 37 / HEIGHT_6S_SCALE)];
        partTimeBtn.backgroundColor = [UIColor clearColor];
        [partTimeBtn setTitle:@"兼职" forState:UIControlStateNormal];
        [partTimeBtn setTitleColor:getColor(blackColor) forState:UIControlStateNormal];
        partTimeBtn.layer.borderColor = getColor(dividerColor).CGColor;
        partTimeBtn.layer.borderWidth = 1.5;
        partTimeBtn.titleLabel.font = DEF_FontSize_14;
        [partTimeBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
        self.partTimeBtn = partTimeBtn;
        [_footerView addSubview:partTimeBtn];
        
        UILabel *sffsLabel = [[UILabel alloc]initWithFrame:CGRectMake(10 / WIDTH_6S_SCALE, CGRectGetMaxY(fullTimeBtn.frame) + 20 / HEIGHT_6S_SCALE, 100 / WIDTH_6S_SCALE, 20 / HEIGHT_6S_SCALE)];
        sffsLabel.backgroundColor = [UIColor clearColor];
        sffsLabel.textColor = getColor(blackColor);
        sffsLabel.font = DEF_FontSize_14;
        sffsLabel.textAlignment = NSTextAlignmentLeft;
        sffsLabel.text = @"收费方式";
        [_footerView addSubview:sffsLabel];
        
        UIButton *pleaseChooseTypeBtn = [[UIButton alloc]init];
        pleaseChooseTypeBtn.backgroundColor = [UIColor clearColor];
        [pleaseChooseTypeBtn setTitle:@"  请选择  >" forState:UIControlStateNormal];
        [pleaseChooseTypeBtn setTitleColor:getColor(blackColor) forState:UIControlStateNormal];
        pleaseChooseTypeBtn.titleLabel.font = DEF_FontSize_14;
        pleaseChooseTypeBtn.titleLabel.textAlignment = NSTextAlignmentRight;
        [pleaseChooseTypeBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
        self.pleaseChooseTypeBtn = pleaseChooseTypeBtn;
        [_footerView addSubview:pleaseChooseTypeBtn];
        [pleaseChooseTypeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(sffsLabel.mas_centerY);
            make.right.equalTo(partTimeBtn.mas_right);
            make.width.mas_equalTo(100 / WIDTH_6S_SCALE);
            make.height.mas_equalTo(30 / HEIGHT_6S_SCALE);
        }];
        
        UIView *lineView2 = [[UIView alloc]initWithFrame:CGRectMake(10 / WIDTH_6S_SCALE, CGRectGetMaxY(sffsLabel.frame) + 15 / HEIGHT_6S_SCALE, SCREEN_WIDTH, 0.5)];
        lineView2.backgroundColor = getColor(dividerColor);
        [_footerView addSubview:lineView2];
        
        UILabel *priceLabel = [[UILabel alloc]initWithFrame:CGRectMake(10 / WIDTH_6S_SCALE, CGRectGetMaxY(lineView2.frame) + 20 / HEIGHT_6S_SCALE, 100 / WIDTH_6S_SCALE, 20 / HEIGHT_6S_SCALE)];
        priceLabel.backgroundColor = [UIColor clearColor];
        priceLabel.textColor = getColor(blackColor);
        priceLabel.font = DEF_FontSize_14;
        priceLabel.textAlignment = NSTextAlignmentLeft;
        priceLabel.text = @"价格";
        [_footerView addSubview:priceLabel];
        
        UIView *lineView3 = [[UIView alloc]initWithFrame:CGRectMake(10 / WIDTH_6S_SCALE, CGRectGetMaxY(priceLabel.frame) + 20 / HEIGHT_6S_SCALE, SCREEN_WIDTH, 0.5)];
        lineView3.backgroundColor = getColor(dividerColor);
        [_footerView addSubview:lineView3];
        
        UILabel *yuanLabel = [[UILabel alloc]init];
        yuanLabel.backgroundColor = [UIColor clearColor];
        yuanLabel.textColor = getColor(blackColor);
        yuanLabel.font = DEF_FontSize_14;
        yuanLabel.textAlignment = NSTextAlignmentRight;
        yuanLabel.text = @"元";
        [_footerView addSubview:yuanLabel];
        [yuanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(priceLabel.mas_centerY);
            make.right.equalTo(partTimeBtn.mas_right);
            make.width.mas_equalTo(20 / WIDTH_6S_SCALE);
            make.height.mas_equalTo(30 / HEIGHT_6S_SCALE);
        }];
        
        UITextField *priceField = [[UITextField alloc]init];
        priceField.backgroundColor = [UIColor clearColor];
        priceField.textColor = getColor(textColor);
        priceField.textAlignment = NSTextAlignmentRight;
        priceField.font = DEF_FontSize_14;
        priceField.placeholder = @"请输入价格";
        self.priceField = priceField;
        [_footerView addSubview:priceField];
        [priceField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(priceLabel.mas_centerY);
            make.right.equalTo(yuanLabel.mas_left);
            make.width.mas_equalTo(100 / WIDTH_6S_SCALE);
            make.height.mas_equalTo(30 / HEIGHT_6S_SCALE);
        }];
        
        _submmitButton = [[UIButton alloc] initWithFrame:CGRectMake(20 / WIDTH_6S_SCALE, 180 / HEIGHT_6S_SCALE, SCREEN_WIDTH - 40 / WIDTH_6S_SCALE, 45 / WIDTH_5S_SCALE)];
        _submmitButton.backgroundColor = getColor(mainColor);
        _submmitButton.layer.cornerRadius = 5 / WIDTH_5S_SCALE;
        _submmitButton.layer.masksToBounds = YES;
        [_submmitButton setTitle:@"保存信息" forState:UIControlStateNormal];
        [_submmitButton setTitleColor:getColor(whiteColor) forState:UIControlStateNormal];
        _submmitButton.titleLabel.font = DEF_FontSize_16;
        [_submmitButton addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
        [_footerView addSubview:_submmitButton];
    }
    return _footerView;
}

- (NSMutableArray *)dataArray{
    if (!_dataArray) {
        _dataArray = @[].mutableCopy;
    }
    return _dataArray;
}
@end


